#include"traitDemo.h"
#include <iostream>

class A
{
public:
    int i;
};
class B:public A
{
    int i;
};



void traitDemo()
{
    using namespace std;
    cout <<" is_same add_const ? "   << std::is_same<const int, std::add_const<int>::type>::value << endl; //结果为true
    cout <<" is_same add_const ? "   << std::is_same<const int, std::remove_pointer<int *>::type>::value << endl;
    cout << std::is_same<int, std::remove_all_extents<int[2][2][3]>::type>::value<<endl;

    A a;
    B b;


    std::remove_all_extents<int[2][2][3]>::type j;
    typeof(typeof(char *)[4]) y;
    int *x;
    typeof(*x) y1;
    cout <<"y1 is_same int * ? "  << is_same<int *, typeof(y1)>::value << endl;

    // cout <<" typeof  "   << typeof(j)  << endl;

    cout <<"a is_same A ? "  << is_same<A, typeof(a)>::value << endl;
    cout <<"a is_same B ? "  << is_same<B, typeof(a)>::value << endl;
    cout <<"b is_same A ?"  << std::is_same<A, typeof(b)>::value << endl;
    cout <<"b is_same B ?"  << std::is_same<B, typeof(b)>::value << endl;

    cout <<"A is_base_of B ? "  << std::is_base_of<A, B>::value << endl;
    cout <<"B is_base_of A ? "  << std::is_base_of<B, A>::value << endl;

    cout <<"a is_base_of A ? "  << std::is_base_of<A, typeof(a)>::value << endl;
    cout <<"a is_base_of B ? "  << std::is_base_of<B, typeof(a)>::value << endl;
    cout <<"b is_base_of A ?"  << std::is_base_of<A, typeof(b)>::value << endl;
    cout <<"b is_base_of B ?"  << std::is_base_of<B, typeof(b)>::value << endl;

    cout <<"A is_convertible B ? "  << std::is_convertible<A, B>::value << endl;
    cout <<"B is_convertible A ? "  << std::is_convertible<B, A>::value << endl;
    cout <<"a is_convertible A ? "  << std::is_convertible<A, typeof(a)>::value << endl;
    cout <<"a is_convertible B ? "  << std::is_convertible<typeof(a),B>::value << endl;
    cout <<"b is_convertible A ?"  << std::is_convertible<typeof(b),A>::value << endl;
    cout <<"b is_convertible B ?"  << std::is_convertible<B, typeof(b)>::value << endl;

    A *a1=&b;
    //   B *b1=&a;

}
